
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Banco de Questões</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    
    <style type="text/css">
      body {
        padding-top: 40px;
        padding-bottom: 40px;
        background-color: #f5f5f5;
      }

      .form-signin {
        max-width: 300px;
        padding: 19px 29px 29px;
        margin: 0 auto 20px;
        background-color: #fff;
        border: 1px solid #e5e5e5;
        -webkit-border-radius: 5px;
           -moz-border-radius: 5px;
                border-radius: 5px;
        -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.05);
           -moz-box-shadow: 0 1px 2px rgba(0,0,0,.05);
                box-shadow: 0 1px 2px rgba(0,0,0,.05);
      }
      .form-signin .form-signin-heading,
      .form-signin .checkbox {
        margin-bottom: 10px;
      }
      .form-signin input[type="text"],
      .form-signin input[type="password"] {
        font-size: 16px;
        height: auto;
        margin-bottom: 15px;
        padding: 7px 9px;
      }

    </style>
    <link href="<?= base_url() ?>assets/css/bootstrap.min.css" rel="stylesheet">
    <link href="<?= base_url() ?>assets/css/datepicker.css" rel="stylesheet">
    <link href="<?= base_url() ?>assets/css/base.css" rel="stylesheet">
    <link href="<?= base_url() ?>assets/css/bootstrap-responsive.css" rel="stylesheet">
    
    
    
  </head>

  <body>
  
      <div class="form-signin" id="form">
        <div class="alert alert-error" id="mensagem">Login e Senha Inválidos</div>
        <div class="text-center">
          <h2 class="form-signin-heading">Banco de Questões</h2>
        </div>
        <input type="text" class="input-block-level" placeholder="Usuário" id="login">
        <input type="password" class="input-block-level" placeholder="Senha" id="senha">
        <button class="btn btn-large btn-primary" id="submitButton">Entrar</button>
      </div>
      
    <script src="<?= base_url() ?>assets/js/jquery.min.js"></script>
    <script src="<?= base_url() ?>assets/js/bootstrap.min.js"></script>
    <script src="<?= base_url() ?>assets/js/base.js"></script>
    
    <script type="text/javascript">
        var base_url = '<?= base_url() ?>';

        $(document).ready(function(){
            $('#mensagem').hide();
            $('#submitButton').click(autenticar);
            $(document).keypress(function(e) {
                if(e.which == 13) {
                    autenticar();
                }
            });
        });

        function autenticar(){
          modal.carregando();
          var data = {login: $('#login').val(), senha: $('#senha').val() };

          $.ajax({
            url: '<?= base_url() ?>usuario/autenticar',
            data: data,
            type: 'POST',
            success: function(error){
              if(error){
                $('#mensagem').text(error);
                $('#mensagem').show();  
              } else{
                location.href = '<?= base_url() ?>';
              }
            },
            error: function(){
              $('#mensagem').hide();
            }
          });
        }

    </script>

  </body>
</html>
